<div class="myRightType">
	<div class="title">
		跟随者列表
	</div>
	<div class="inner">
		<div class="box clearfix">
			<div class="row">
				<div class="col-md-2">
					<p>跟随者列表</p>
				</div>
				<div class="col-md-10 tr">

					<div class="search rfoat">
						<input type="text" placeholder="输入MT5账号" id="Fllow_mt5" />
						<i class="glyphicon glyphicon-search" id="Fllow_search"></i>

					</div>

				</div>
			</div>
			<br />
			<table id="fllowList" class="clearfix"></table>

		</div>
	</div>
</div>
<div id="fllowMore" style="display: none;">
	<div class="wrap">

		<div class="row">

			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：
				</div>
				<div class="col-md-4 col-sm-4" id="mtLogin">
					0
				</div>

			</div>

		</div>
		<div class="row">

			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					跟单大牛数：
				</div>
				<div class="col-md-4 col-sm-4" id="followDanielNumber">
					0
				</div>

			</div>
			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					余&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;额：
				</div>
				<div class="col-md-4 col-sm-4" id="banlance">
					0
				</div>

			</div>
			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					累计盈利：
				</div>
				<div class="col-md-4 col-sm-4" id="cumulativeProfit">
					0
				</div>

			</div>
			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					交易时长：
				</div>
				<div class="col-md-4 col-sm-4" id="createTime">
					0
				</div>

			</div>

		</div>
		<div class="row">

			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					昵&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称：
				</div>
				<div class="col-md-4 col-sm-4" id="documentaryNumber">
					0
				</div>

			</div>
			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					年化收益：
				</div>
				<div class="col-md-4 col-sm-4" id="annualIncome">
					0
				</div>

			</div>
			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					最大撤回：
				</div>
				<div class="col-md-4 col-sm-4" id="maximumWithdrawal">
					0
				</div>

			</div>
			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					累计入金：
				</div>
				<div class="col-md-4 col-sm-4" id="cumulativeIntoGold">
					0
				</div>

			</div>

		</div>
		<div class="row">

			<div class="col-md-3 col-sm-3">
				<div class="col-md-8 blue col-sm-8">
					累计出金：
				</div>
				<div class="col-md-4 col-sm-4" id="cumulativeOutGold">
					0
				</div>

			</div>

		</div>
		<table id="fllowMoreTable"></table>
	</div>
</div>
<script type="text/javascript">
	$('#fllowList').bootstrapTable({
		url: "/wechat_mt5/admin/follower/list",
		method: 'get',
		columns: [{
			field: 'mtLogin',
			title: '交易账号'
		}, {
			field: 'danielNumber',
			title: '绑定大牛数',

		}, {
			field: 'banlance',
			title: '余额',
			formatter: banlance

		}, {
			field: 'profit',
			title: '累计盈利',

		}, {
			field: 'createTime',
			title: '交易时长',
			formatter: time

		}, {
			field: 'state',
			title: '操作',
			formatter: doWorld,
		}],
		height: 650,
		pageSize: 10,
		pageList: [10, 25, 50, 100],
		showRefresh: true,
		editable: true,
		// onClickRow:operateEvents,
		// showColumns: true,
		pagination: true,
		//		  striped: true,
		sidePagination: 'server',

	});

	function time(value) {
		var start = new Date(value);
		var end = new Date();
		var difference = end.getTime() - start.getTime()
		return days = Math.floor(difference / (24 * 3600 * 1000)) + "天"
	}

	function banlance(value) {
		if(value) {
			value *= 1
			if(value > 0) {
				return "<span class='green'>" + changeMoney(value) + "</span>";
			} else {
				return "<span class='red'>" + changeMoney(value) + "</span>";
			}
		} else {
			return "-";
		}

	}
	lookSearch($("#Fllow_search"), $("#Fllow_mt5"), $('#fllowList'));

	function doWorld(value, row) {
		var info = JSON.stringify(row);
		if(value == "0") {
			return "<button type='button' class='btn btn-primary' onclick='moreFllow(" + info + ")'>详情</button><button type='button' class='btn btn-danger' onclick='freeze(" + info + ")'>冻结</button>"

		} else {
			return "<button type='button' class='btn btn-primary' onclick='moreFllow(" + info + ")'>详情</button><button type='button' class='btn btn-success' onclick='noFreeze(" + info + ")'>解冻</button>"

		}

	}

	function freeze(info) {
		layui.use('layer', function() {
			var layer = layui.layer;
			layer.open({
				content: '您确定冻结' + info.mtLogin,
				btn: ['确定', '取消'],
				yes: function(index, layero) {
					$.ajax({
						type: "put",
						data: {
							userId: info.userId,
							updateTime: info.updateTime
						},
						url: "/wechat_mt5/admin/disabled/user",

						success: function(data) {
							if(data.data) {
								prompt("冻结成功！");
								$('#fllowList').bootstrapTable(
									"refresh", {
										url: "/wechat_mt5/admin/follower/list"
									}
								);

							} else {
								prompt("冻结失败！");
							}
						}

					})
				},
				btn2: function(index, layero) {
					layer.close(index)
						//按钮【按钮二】的回调

					//return false 开启该代码可禁止点击该按钮关闭
				}
			});

		});

	}

	function noFreeze(info) {
		layui.use('layer', function() {
			var layer = layui.layer;
			layer.open({
				content: '您确定解冻' + info.mtLogin,
				btn: ['确定', '取消'],
				yes: function(index, layero) {
					$.ajax({
						type: "put",
						data: {
							userId: info.userId,
							updateTime: info.updateTime
						},
						url: "/wechat_mt5/admin/thaw/user",

						success: function(data) {
							if(data.data) {
								prompt("解冻成功！");
								$('#fllowList').bootstrapTable(
									"refresh", {
										url: "/wechat_mt5/admin/follower/list"
									}
								);

							} else {
								prompt("解冻失败！");
							}
						}

					})
				},
				btn2: function(index, layero) {
					layer.close(index)
						//按钮【按钮二】的回调

					//return false 开启该代码可禁止点击该按钮关闭
				}
			});

		});

	}

	function moreFllow(info) {

		$.ajax({
			type: "get",
			url: "/wechat_mt5/admin/follower/details",
			data: {
				mtLogin: info.mtLogin
			},
			success: function(data) {
				if(data.code == "0") {
					for(x in data.data) {
						if(typeof data.data[x] == "number") {
							$("#" + x).html(changeMoney(data.data[x]))

						} else {
							$("#" + x).html(data.data[x])

						}

					}
					$('#fllowMoreTable').bootstrapTable({
						url: "/wechat_mt5/admin/follower/details/table",
						method: 'get',
						queryParams: {
							mtLogin: info.mtLogin
						},
						columns: [{
							field: 'sourceLogin',
							title: '跟单大牛列表'
						}, {
							field: 'followingOrderNumberHistory',
							title: '历史跟随订单数',

						}, {
							field: 'volumeHistory',
							title: '历史跟单手数',

						}, {
							field: 'orderNumberPosition',
							title: '当前持仓订单数',

						}, {
							field: 'volumePosition',
							title: '当前持仓手数',

						}],
						height: 500,
						pageSize: 10,
						pageList: [10, 25, 50, 100],
						showRefresh: true,
						editable: true,
						// onClickRow:operateEvents,
						// showColumns: true,
						pagination: true,
						//		  striped: true,
						sidePagination: 'server',

					});

					$('#createTime').html(time(data.data.createTime))
					alertNew("查看详情", "963", "794", $("#fllowMore"));

				}
			}

		})

	}
</script>